home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-02-01 | 3.4 KB | 88 lines | [TEXT/ToyS] |
- property fontDlog : {bounds:null, contents:[¬
- {class:push button, bounds:[190, 200, 250, 220], name:"OK"}, ¬
- {class:push button, bounds:[110, 200, 170, 220], name:"Cancel"}, ¬
- {class:pop up, name:"Font:", bounds:[7, 8, 250, 28], contents:"FONT"}, ¬
- {class:pop up, bounds:[96, 35, 96, 55], contents:"9;10;12;14;18;24;36;48", text field:5}, ¬
- {class:text field, bounds:[50, 37, 90, 53], name:"Size:", name bounds:[10, 37, 48, 53]}, ¬
- {class:check box, name:"Plain", bounds:[60, 60, 150, 76]}, ¬
- {class:check box, name:"Bold", bounds:[60, 76, 150, 92], enabled:-6}, ¬
- {class:check box, name:"Italic", bounds:[60, 92, 150, 108], enabled:-6}, ¬
- {class:check box, name:"Underline", bounds:[60, 108, 150, 124], enabled:-6}, ¬
- {class:check box, name:"Outline", bounds:[60, 124, 150, 140], enabled:-6}, ¬
- {class:check box, name:"Shadow", bounds:[60, 140, 150, 156], enabled:-6}, ¬
- {class:check box, name:"Condensed", bounds:[60, 156, 150, 172], enabled:-6}, ¬
- {class:check box, name:"Extended", bounds:[60, 172, 150, 188], enabled:-6}, ¬
- {class:static text, bounds:[10, 60, 50, 76], contents:"Style:"} ¬
- ], style:movable dialog, name:"Edit Font"}
-
- on EditFontSpec(fs)
- set s to fs's style
- if s's class = integer then
- set R to [fs's name, 1, fs's size, s = 0, s mod 2 = 1]
- repeat 6 times
- set s to s div 2
- set R to R & (s mod 2 = 1)
- end repeat
- else
- set s to s as list
- set R to [fs's name, 1, fs's size, s = [] or s contains plain, s contains bold, ¬
- s contains italic, s contains underline, s contains outline, ¬
- s contains shadow, s contains condensed, s contains expanded]
- end if
- if fontDlog's bounds = null then set fontDlog's bounds to dd calc dialog bounds [260, 230]
- dd set value of items 3 thru 13 of (dd make dialog fontDlog) to R
- repeat
- set i to dd interact with user
- if i = 1 then
- try
- set siz to (dd get value of item 5 of dialog 1) as integer
- if siz < 4 or siz > 127 then error
- exit repeat
- on error
- beep 1
- Alert(1, "Invalid font size!", ¬
- "The font size must be an integer between 4 and 127.", "OK", "")
- dd set selection of item 5 of dialog 1 to [0, -1]
- end try
- else if i = 2 then
- exit repeat
- end if
- end repeat
- set f to dd get value of every item of dialog 1
- dd delete dialog 1
- set bounds of fontDlog to last item of f
- tell f
- if item 2 then return fs
- set s to []
- if not item 6 then
- if item 7 then set s to [bold]
- if item 8 then set s to s & italic
- if item 9 then set s to s & underline
- if item 10 then set s to s & outline
- if item 11 then set s to s & shadow
- if item 12 then set s to s & condensed
- if item 13 then set s to s & expanded
- end if
- if s = [] then
- set s to plain
- else if s's length = 1 then
- set s to s's item 1
- end if
- return {name:item 3, size:siz, style:s}
- end tell
- end EditFontSpec
-
- on Alert(icn, msg1, msg2, btn1, btn2)
- set c to [{class:push button, bounds:[295, 83, 353, 103], name:btn1}]
- if btn2 ≠ "" then set c to c & [{class:push button, bounds:[225, 83, 283, 103], name:btn2}]
- (dd auto dialog {size:[362, 112], style:movable dialog, contents:c & [¬
- {class:icon, bounds:[17, 9, 17 + 32, 9 + 32], contents:icn}, ¬
- {class:static text, bounds:[67, 9, 352, 9 + 32], contents:msg1}, ¬
- {class:static text, bounds:[67, 45, 352, 45 + 26], contents:msg2, font:5} ¬
- ]})'s item 1
- end Alert
-
- dd install with fonts [null, null, null, null, {name:"Geneva", size:10}] with grayscale
- set fs to EditFontSpec({name:"Times", size:64, style:bold})
- dd uninstall
- return fs